
'===============================================================================
'  Generated From - VbNet_SQL_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  **
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'MustInherit' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can Override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  Public Class YourObject
'    Inherits _YourObject
'
'  End Class
'
'===============================================================================

' Generated by MyGeneration Version # (1.3.0.3)

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Collections.Specialized

Imports MyGeneration.dOOdads

NameSpace Class_RC

Public MustInherit Class _COMPRAS
	Inherits SqlClientEntity

		Public Sub New() 
			Me.QuerySource = "COMPRAS"
			Me.MappingName = "COMPRAS"
		End Sub

	'=================================================================
	'  Public Overrides Sub AddNew()
	'=================================================================
	'
	'=================================================================
	Public Overrides Sub AddNew()
		MyBase.AddNew()
				
	End Sub
	
	Public Overrides Sub FlushData()
		Me._whereClause = nothing
		Me._aggregateClause = nothing		
		MyBase.FlushData()
	End Sub
	
		
	'=================================================================
	'  	Public Function LoadAll() As Boolean
	'=================================================================
	'  Loads all of the records in the database, and sets the currentRow to the first row
	'=================================================================
	Public Function LoadAll() As Boolean
	
		Dim parameters As ListDictionary = Nothing
		
		
    	Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_COMPRASLoadAll]", parameters)
		
	End Function

	'=================================================================
	' Public Overridable Function LoadByPrimaryKey()  As Boolean
	'=================================================================
	'  Loads a single row of via the primary key
	'=================================================================
        Public Overridable Function LoadByPrimaryKey(ByVal CodCompra As Integer) As Boolean

            Dim parameters As ListDictionary = New ListDictionary()
            parameters.Add(_COMPRAS.Parameters.CodCompra, CodCompra)


            Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_COMPRASLoadByPrimaryKey]", parameters)

        End Function

#Region "Parameters"
        Protected Class Parameters

            Public Shared ReadOnly Property CodCompra As SqlParameter
                Get
                    Return New SqlParameter("@CodCompra", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property NroFactura As SqlParameter
                Get
                    Return New SqlParameter("@NroFactura", SqlDbType.NVarChar, 50)
                End Get
            End Property

            Public Shared ReadOnly Property Fecha As SqlParameter
                Get
                    Return New SqlParameter("@Fecha", SqlDbType.DateTime, 0)
                End Get
            End Property

            Public Shared ReadOnly Property Vencimiento As SqlParameter
                Get
                    Return New SqlParameter("@Vencimiento", SqlDbType.DateTime, 0)
                End Get
            End Property

            Public Shared ReadOnly Property TipoCompra As SqlParameter
                Get
                    Return New SqlParameter("@TipoCompra", SqlDbType.NVarChar, 50)
                End Get
            End Property

            Public Shared ReadOnly Property EstadoCompra As SqlParameter
                Get
                    Return New SqlParameter("@EstadoCompra", SqlDbType.NVarChar, 50)
                End Get
            End Property

            Public Shared ReadOnly Property TotalCompra As SqlParameter
                Get
                    Return New SqlParameter("@TotalCompra", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property TotalCompraSaldo As SqlParameter
                Get
                    Return New SqlParameter("@TotalCompraSaldo", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property TotalCompraIVA As SqlParameter
                Get
                    Return New SqlParameter("@TotalCompraIVA", SqlDbType.Decimal, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CodProveedor As SqlParameter
                Get
                    Return New SqlParameter("@CodProveedor", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property CodUsuario As SqlParameter
                Get
                    Return New SqlParameter("@CodUsuario", SqlDbType.Int, 0)
                End Get
            End Property

            Public Shared ReadOnly Property FechaActualizacion As SqlParameter
                Get
                    Return New SqlParameter("@FechaActualizacion", SqlDbType.DateTime, 0)
                End Get
            End Property

            Public Shared ReadOnly Property NroRemision As SqlParameter
                Get
                    Return New SqlParameter("@NroRemision", SqlDbType.NVarChar, 50)
                End Get
            End Property

            Public Shared ReadOnly Property CodOrden As SqlParameter
                Get
                    Return New SqlParameter("@CodOrden", SqlDbType.Int, 0)
                End Get
            End Property

        End Class
#End Region

#Region "ColumnNames"
        Public Class ColumnNames

            Public Const CodCompra As String = "codCompra"
            Public Const NroFactura As String = "nroFactura"
            Public Const Fecha As String = "fecha"
            Public Const Vencimiento As String = "vencimiento"
            Public Const TipoCompra As String = "tipoCompra"
            Public Const EstadoCompra As String = "estadoCompra"
            Public Const TotalCompra As String = "totalCompra"
            Public Const TotalCompraSaldo As String = "totalCompraSaldo"
            Public Const TotalCompraIVA As String = "totalCompraIVA"
            Public Const CodProveedor As String = "codProveedor"
            Public Const CodUsuario As String = "codUsuario"
            Public Const FechaActualizacion As String = "fechaActualizacion"
            Public Const NroRemision As String = "nroRemision"
            Public Const CodOrden As String = "codOrden"

            Public Shared Function ToPropertyName(ByVal columnName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(CodCompra) = _COMPRAS.PropertyNames.CodCompra
                    ht(NroFactura) = _COMPRAS.PropertyNames.NroFactura
                    ht(Fecha) = _COMPRAS.PropertyNames.Fecha
                    ht(Vencimiento) = _COMPRAS.PropertyNames.Vencimiento
                    ht(TipoCompra) = _COMPRAS.PropertyNames.TipoCompra
                    ht(EstadoCompra) = _COMPRAS.PropertyNames.EstadoCompra
                    ht(TotalCompra) = _COMPRAS.PropertyNames.TotalCompra
                    ht(TotalCompraSaldo) = _COMPRAS.PropertyNames.TotalCompraSaldo
                    ht(TotalCompraIVA) = _COMPRAS.PropertyNames.TotalCompraIVA
                    ht(CodProveedor) = _COMPRAS.PropertyNames.CodProveedor
                    ht(CodUsuario) = _COMPRAS.PropertyNames.CodUsuario
                    ht(FechaActualizacion) = _COMPRAS.PropertyNames.FechaActualizacion
                    ht(NroRemision) = _COMPRAS.PropertyNames.NroRemision
                    ht(CodOrden) = _COMPRAS.PropertyNames.CodOrden

                End If

                Return CType(ht(columnName), String)

            End Function

            Private Shared ht As Hashtable = Nothing
        End Class
#End Region

#Region "PropertyNames"
        Public Class PropertyNames

            Public Const CodCompra As String = "CodCompra"
            Public Const NroFactura As String = "NroFactura"
            Public Const Fecha As String = "Fecha"
            Public Const Vencimiento As String = "Vencimiento"
            Public Const TipoCompra As String = "TipoCompra"
            Public Const EstadoCompra As String = "EstadoCompra"
            Public Const TotalCompra As String = "TotalCompra"
            Public Const TotalCompraSaldo As String = "TotalCompraSaldo"
            Public Const TotalCompraIVA As String = "TotalCompraIVA"
            Public Const CodProveedor As String = "CodProveedor"
            Public Const CodUsuario As String = "CodUsuario"
            Public Const FechaActualizacion As String = "FechaActualizacion"
            Public Const NroRemision As String = "NroRemision"
            Public Const CodOrden As String = "CodOrden"

            Public Shared Function ToColumnName(ByVal propertyName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(CodCompra) = _COMPRAS.ColumnNames.CodCompra
                    ht(NroFactura) = _COMPRAS.ColumnNames.NroFactura
                    ht(Fecha) = _COMPRAS.ColumnNames.Fecha
                    ht(Vencimiento) = _COMPRAS.ColumnNames.Vencimiento
                    ht(TipoCompra) = _COMPRAS.ColumnNames.TipoCompra
                    ht(EstadoCompra) = _COMPRAS.ColumnNames.EstadoCompra
                    ht(TotalCompra) = _COMPRAS.ColumnNames.TotalCompra
                    ht(TotalCompraSaldo) = _COMPRAS.ColumnNames.TotalCompraSaldo
                    ht(TotalCompraIVA) = _COMPRAS.ColumnNames.TotalCompraIVA
                    ht(CodProveedor) = _COMPRAS.ColumnNames.CodProveedor
                    ht(CodUsuario) = _COMPRAS.ColumnNames.CodUsuario
                    ht(FechaActualizacion) = _COMPRAS.ColumnNames.FechaActualizacion
                    ht(NroRemision) = _COMPRAS.ColumnNames.NroRemision
                    ht(CodOrden) = _COMPRAS.ColumnNames.CodOrden

                End If

                Return CType(ht(propertyName), String)

            End Function

            Private Shared ht As Hashtable = Nothing

        End Class
#End Region

#Region "StringPropertyNames"
        Public Class StringPropertyNames

            Public Const CodCompra As String = "s_CodCompra"
            Public Const NroFactura As String = "s_NroFactura"
            Public Const Fecha As String = "s_Fecha"
            Public Const Vencimiento As String = "s_Vencimiento"
            Public Const TipoCompra As String = "s_TipoCompra"
            Public Const EstadoCompra As String = "s_EstadoCompra"
            Public Const TotalCompra As String = "s_TotalCompra"
            Public Const TotalCompraSaldo As String = "s_TotalCompraSaldo"
            Public Const TotalCompraIVA As String = "s_TotalCompraIVA"
            Public Const CodProveedor As String = "s_CodProveedor"
            Public Const CodUsuario As String = "s_CodUsuario"
            Public Const FechaActualizacion As String = "s_FechaActualizacion"
            Public Const NroRemision As String = "s_NroRemision"
            Public Const CodOrden As String = "s_CodOrden"

        End Class
#End Region

#Region "Properties"
        Public Overridable Property CodCompra As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodCompra)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodCompra, Value)
            End Set
        End Property

        Public Overridable Property NroFactura As String
            Get
                Return MyBase.Getstring(ColumnNames.NroFactura)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.NroFactura, Value)
            End Set
        End Property

        Public Overridable Property Fecha As DateTime
            Get
                Return MyBase.GetDateTime(ColumnNames.Fecha)
            End Get
            Set(ByVal Value As DateTime)
                MyBase.SetDateTime(ColumnNames.Fecha, Value)
            End Set
        End Property

        Public Overridable Property Vencimiento As DateTime
            Get
                Return MyBase.GetDateTime(ColumnNames.Vencimiento)
            End Get
            Set(ByVal Value As DateTime)
                MyBase.SetDateTime(ColumnNames.Vencimiento, Value)
            End Set
        End Property

        Public Overridable Property TipoCompra As String
            Get
                Return MyBase.Getstring(ColumnNames.TipoCompra)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.TipoCompra, Value)
            End Set
        End Property

        Public Overridable Property EstadoCompra As String
            Get
                Return MyBase.Getstring(ColumnNames.EstadoCompra)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.EstadoCompra, Value)
            End Set
        End Property

        Public Overridable Property TotalCompra As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.TotalCompra)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.TotalCompra, Value)
            End Set
        End Property

        Public Overridable Property TotalCompraSaldo As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.TotalCompraSaldo)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.TotalCompraSaldo, Value)
            End Set
        End Property

        Public Overridable Property TotalCompraIVA As Decimal
            Get
                Return MyBase.Getdecimal(ColumnNames.TotalCompraIVA)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.Setdecimal(ColumnNames.TotalCompraIVA, Value)
            End Set
        End Property

        Public Overridable Property CodProveedor As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodProveedor)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodProveedor, Value)
            End Set
        End Property

        Public Overridable Property CodUsuario As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodUsuario)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodUsuario, Value)
            End Set
        End Property

        Public Overridable Property FechaActualizacion As DateTime
            Get
                Return MyBase.GetDateTime(ColumnNames.FechaActualizacion)
            End Get
            Set(ByVal Value As DateTime)
                MyBase.SetDateTime(ColumnNames.FechaActualizacion, Value)
            End Set
        End Property

        Public Overridable Property NroRemision As String
            Get
                Return MyBase.Getstring(ColumnNames.NroRemision)
            End Get
            Set(ByVal Value As String)
                MyBase.Setstring(ColumnNames.NroRemision, Value)
            End Set
        End Property

        Public Overridable Property CodOrden As Integer
            Get
                Return MyBase.Getint(ColumnNames.CodOrden)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodOrden, Value)
            End Set
        End Property


#End Region
	
	#Region "String Properties" 

		Public Overridable Property s_CodCompra As String
			Get
				If Me.IsColumnNull(ColumnNames.CodCompra) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodCompra)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodCompra)
				Else
					Me.CodCompra = MyBase.SetintAsString(ColumnNames.CodCompra, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_NroFactura As String
			Get
				If Me.IsColumnNull(ColumnNames.NroFactura) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.NroFactura)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.NroFactura)
				Else
					Me.NroFactura = MyBase.SetstringAsString(ColumnNames.NroFactura, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Fecha As String
			Get
				If Me.IsColumnNull(ColumnNames.Fecha) Then
					Return String.Empty
				Else
					Return MyBase.GetDateTimeAsString(ColumnNames.Fecha)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Fecha)
				Else
					Me.Fecha = MyBase.SetDateTimeAsString(ColumnNames.Fecha, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_Vencimiento As String
			Get
				If Me.IsColumnNull(ColumnNames.Vencimiento) Then
					Return String.Empty
				Else
					Return MyBase.GetDateTimeAsString(ColumnNames.Vencimiento)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.Vencimiento)
				Else
					Me.Vencimiento = MyBase.SetDateTimeAsString(ColumnNames.Vencimiento, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_TipoCompra As String
			Get
				If Me.IsColumnNull(ColumnNames.TipoCompra) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.TipoCompra)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.TipoCompra)
				Else
					Me.TipoCompra = MyBase.SetstringAsString(ColumnNames.TipoCompra, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_EstadoCompra As String
			Get
				If Me.IsColumnNull(ColumnNames.EstadoCompra) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.EstadoCompra)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.EstadoCompra)
				Else
					Me.EstadoCompra = MyBase.SetstringAsString(ColumnNames.EstadoCompra, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_TotalCompra As String
			Get
				If Me.IsColumnNull(ColumnNames.TotalCompra) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.TotalCompra)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.TotalCompra)
				Else
					Me.TotalCompra = MyBase.SetdecimalAsString(ColumnNames.TotalCompra, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_TotalCompraSaldo As String
			Get
				If Me.IsColumnNull(ColumnNames.TotalCompraSaldo) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.TotalCompraSaldo)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.TotalCompraSaldo)
				Else
					Me.TotalCompraSaldo = MyBase.SetdecimalAsString(ColumnNames.TotalCompraSaldo, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_TotalCompraIVA As String
			Get
				If Me.IsColumnNull(ColumnNames.TotalCompraIVA) Then
					Return String.Empty
				Else
					Return MyBase.GetdecimalAsString(ColumnNames.TotalCompraIVA)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.TotalCompraIVA)
				Else
					Me.TotalCompraIVA = MyBase.SetdecimalAsString(ColumnNames.TotalCompraIVA, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodProveedor As String
			Get
				If Me.IsColumnNull(ColumnNames.CodProveedor) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodProveedor)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodProveedor)
				Else
					Me.CodProveedor = MyBase.SetintAsString(ColumnNames.CodProveedor, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodUsuario As String
			Get
				If Me.IsColumnNull(ColumnNames.CodUsuario) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodUsuario)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodUsuario)
				Else
					Me.CodUsuario = MyBase.SetintAsString(ColumnNames.CodUsuario, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_FechaActualizacion As String
			Get
				If Me.IsColumnNull(ColumnNames.FechaActualizacion) Then
					Return String.Empty
				Else
					Return MyBase.GetDateTimeAsString(ColumnNames.FechaActualizacion)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.FechaActualizacion)
				Else
					Me.FechaActualizacion = MyBase.SetDateTimeAsString(ColumnNames.FechaActualizacion, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_NroRemision As String
			Get
				If Me.IsColumnNull(ColumnNames.NroRemision) Then
					Return String.Empty
				Else
					Return MyBase.GetstringAsString(ColumnNames.NroRemision)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.NroRemision)
				Else
					Me.NroRemision = MyBase.SetstringAsString(ColumnNames.NroRemision, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodOrden As String
			Get
				If Me.IsColumnNull(ColumnNames.CodOrden) Then
					Return String.Empty
				Else
					Return MyBase.GetintAsString(ColumnNames.CodOrden)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodOrden)
				Else
					Me.CodOrden = MyBase.SetintAsString(ColumnNames.CodOrden, Value)
				End If
			End Set
		End Property


	#End Region  	

	#Region "Where Clause"
    Public Class WhereClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffWhereParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffWhereParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "TearOff's"
		Public class TearOffWhereParameter

			Public Sub New(ByVal clause As WhereClause)
				Me._clause = clause
			End Sub
		
	
			Public ReadOnly Property CodCompra() As WhereParameter
				Get
					Dim where As WhereParameter = New WhereParameter(ColumnNames.CodCompra, Parameters.CodCompra)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property NroFactura() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.NroFactura, Parameters.NroFactura)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Fecha() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Fecha, Parameters.Fecha)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property Vencimiento() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.Vencimiento, Parameters.Vencimiento)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property TipoCompra() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.TipoCompra, Parameters.TipoCompra)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property EstadoCompra() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.EstadoCompra, Parameters.EstadoCompra)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property TotalCompra() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.TotalCompra, Parameters.TotalCompra)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property TotalCompraSaldo() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.TotalCompraSaldo, Parameters.TotalCompraSaldo)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property TotalCompraIVA() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.TotalCompraIVA, Parameters.TotalCompraIVA)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodProveedor() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodProveedor, Parameters.CodProveedor)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodUsuario() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodUsuario, Parameters.CodUsuario)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property FechaActualizacion() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.FechaActualizacion, Parameters.FechaActualizacion)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property NroRemision() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.NroRemision, Parameters.NroRemision)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodOrden() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodOrden, Parameters.CodOrden)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property


			Private _clause as WhereClause
		End Class
		#End Region	

		Public ReadOnly Property CodCompra() As WhereParameter 
			Get
				If _CodCompra_W Is Nothing Then
					_CodCompra_W = TearOff.CodCompra
				End If
				Return _CodCompra_W
			End Get
		End Property

		Public ReadOnly Property NroFactura() As WhereParameter 
			Get
				If _NroFactura_W Is Nothing Then
					_NroFactura_W = TearOff.NroFactura
				End If
				Return _NroFactura_W
			End Get
		End Property

		Public ReadOnly Property Fecha() As WhereParameter 
			Get
				If _Fecha_W Is Nothing Then
					_Fecha_W = TearOff.Fecha
				End If
				Return _Fecha_W
			End Get
		End Property

		Public ReadOnly Property Vencimiento() As WhereParameter 
			Get
				If _Vencimiento_W Is Nothing Then
					_Vencimiento_W = TearOff.Vencimiento
				End If
				Return _Vencimiento_W
			End Get
		End Property

		Public ReadOnly Property TipoCompra() As WhereParameter 
			Get
				If _TipoCompra_W Is Nothing Then
					_TipoCompra_W = TearOff.TipoCompra
				End If
				Return _TipoCompra_W
			End Get
		End Property

		Public ReadOnly Property EstadoCompra() As WhereParameter 
			Get
				If _EstadoCompra_W Is Nothing Then
					_EstadoCompra_W = TearOff.EstadoCompra
				End If
				Return _EstadoCompra_W
			End Get
		End Property

		Public ReadOnly Property TotalCompra() As WhereParameter 
			Get
				If _TotalCompra_W Is Nothing Then
					_TotalCompra_W = TearOff.TotalCompra
				End If
				Return _TotalCompra_W
			End Get
		End Property

		Public ReadOnly Property TotalCompraSaldo() As WhereParameter 
			Get
				If _TotalCompraSaldo_W Is Nothing Then
					_TotalCompraSaldo_W = TearOff.TotalCompraSaldo
				End If
				Return _TotalCompraSaldo_W
			End Get
		End Property

		Public ReadOnly Property TotalCompraIVA() As WhereParameter 
			Get
				If _TotalCompraIVA_W Is Nothing Then
					_TotalCompraIVA_W = TearOff.TotalCompraIVA
				End If
				Return _TotalCompraIVA_W
			End Get
		End Property

		Public ReadOnly Property CodProveedor() As WhereParameter 
			Get
				If _CodProveedor_W Is Nothing Then
					_CodProveedor_W = TearOff.CodProveedor
				End If
				Return _CodProveedor_W
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As WhereParameter 
			Get
				If _CodUsuario_W Is Nothing Then
					_CodUsuario_W = TearOff.CodUsuario
				End If
				Return _CodUsuario_W
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As WhereParameter 
			Get
				If _FechaActualizacion_W Is Nothing Then
					_FechaActualizacion_W = TearOff.FechaActualizacion
				End If
				Return _FechaActualizacion_W
			End Get
		End Property

		Public ReadOnly Property NroRemision() As WhereParameter 
			Get
				If _NroRemision_W Is Nothing Then
					_NroRemision_W = TearOff.NroRemision
				End If
				Return _NroRemision_W
			End Get
		End Property

		Public ReadOnly Property CodOrden() As WhereParameter 
			Get
				If _CodOrden_W Is Nothing Then
					_CodOrden_W = TearOff.CodOrden
				End If
				Return _CodOrden_W
			End Get
		End Property

		Private _CodCompra_W As WhereParameter = Nothing
		Private _NroFactura_W As WhereParameter = Nothing
		Private _Fecha_W As WhereParameter = Nothing
		Private _Vencimiento_W As WhereParameter = Nothing
		Private _TipoCompra_W As WhereParameter = Nothing
		Private _EstadoCompra_W As WhereParameter = Nothing
		Private _TotalCompra_W As WhereParameter = Nothing
		Private _TotalCompraSaldo_W As WhereParameter = Nothing
		Private _TotalCompraIVA_W As WhereParameter = Nothing
		Private _CodProveedor_W As WhereParameter = Nothing
		Private _CodUsuario_W As WhereParameter = Nothing
		Private _FechaActualizacion_W As WhereParameter = Nothing
		Private _NroRemision_W As WhereParameter = Nothing
		Private _CodOrden_W As WhereParameter = Nothing

			Public Sub WhereClauseReset()

			_CodCompra_W = Nothing
			_NroFactura_W = Nothing
			_Fecha_W = Nothing
			_Vencimiento_W = Nothing
			_TipoCompra_W = Nothing
			_EstadoCompra_W = Nothing
			_TotalCompra_W = Nothing
			_TotalCompraSaldo_W = Nothing
			_TotalCompraIVA_W = Nothing
			_CodProveedor_W = Nothing
			_CodUsuario_W = Nothing
			_FechaActualizacion_W = Nothing
			_NroRemision_W = Nothing
			_CodOrden_W = Nothing
				Me._entity.Query.FlushWhereParameters()

			End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffWhereParameter
    End Class	

	Public ReadOnly Property Where() As WhereClause
		Get
			If _whereClause Is Nothing Then
				_whereClause = New WhereClause(Me)
			End If
	
			Return _whereClause
		End Get
	End Property
	
	Private _whereClause As WhereClause = Nothing	
#End Region	

#Region "Aggregate Clause"
    Public Class AggregateClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffAggregateParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffAggregateParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "AggregateParameter TearOff's"
		Public class TearOffAggregateParameter

			Public Sub New(ByVal clause As AggregateClause)
				Me._clause = clause
			End Sub
		
	
		Public ReadOnly Property CodCompra() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodCompra, Parameters.CodCompra)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property NroFactura() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.NroFactura, Parameters.NroFactura)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Fecha() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Fecha, Parameters.Fecha)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property Vencimiento() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.Vencimiento, Parameters.Vencimiento)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property TipoCompra() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.TipoCompra, Parameters.TipoCompra)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property EstadoCompra() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.EstadoCompra, Parameters.EstadoCompra)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property TotalCompra() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.TotalCompra, Parameters.TotalCompra)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property TotalCompraSaldo() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.TotalCompraSaldo, Parameters.TotalCompraSaldo)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property TotalCompraIVA() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.TotalCompraIVA, Parameters.TotalCompraIVA)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodProveedor() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodProveedor, Parameters.CodProveedor)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodUsuario, Parameters.CodUsuario)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.FechaActualizacion, Parameters.FechaActualizacion)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property NroRemision() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.NroRemision, Parameters.NroRemision)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodOrden() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodOrden, Parameters.CodOrden)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property


			Private _clause as AggregateClause
		End Class
		#End Region	

		Public ReadOnly Property CodCompra() As AggregateParameter 
			Get
				If _CodCompra_W Is Nothing Then
					_CodCompra_W = TearOff.CodCompra
				End If
				Return _CodCompra_W
			End Get
		End Property

		Public ReadOnly Property NroFactura() As AggregateParameter 
			Get
				If _NroFactura_W Is Nothing Then
					_NroFactura_W = TearOff.NroFactura
				End If
				Return _NroFactura_W
			End Get
		End Property

		Public ReadOnly Property Fecha() As AggregateParameter 
			Get
				If _Fecha_W Is Nothing Then
					_Fecha_W = TearOff.Fecha
				End If
				Return _Fecha_W
			End Get
		End Property

		Public ReadOnly Property Vencimiento() As AggregateParameter 
			Get
				If _Vencimiento_W Is Nothing Then
					_Vencimiento_W = TearOff.Vencimiento
				End If
				Return _Vencimiento_W
			End Get
		End Property

		Public ReadOnly Property TipoCompra() As AggregateParameter 
			Get
				If _TipoCompra_W Is Nothing Then
					_TipoCompra_W = TearOff.TipoCompra
				End If
				Return _TipoCompra_W
			End Get
		End Property

		Public ReadOnly Property EstadoCompra() As AggregateParameter 
			Get
				If _EstadoCompra_W Is Nothing Then
					_EstadoCompra_W = TearOff.EstadoCompra
				End If
				Return _EstadoCompra_W
			End Get
		End Property

		Public ReadOnly Property TotalCompra() As AggregateParameter 
			Get
				If _TotalCompra_W Is Nothing Then
					_TotalCompra_W = TearOff.TotalCompra
				End If
				Return _TotalCompra_W
			End Get
		End Property

		Public ReadOnly Property TotalCompraSaldo() As AggregateParameter 
			Get
				If _TotalCompraSaldo_W Is Nothing Then
					_TotalCompraSaldo_W = TearOff.TotalCompraSaldo
				End If
				Return _TotalCompraSaldo_W
			End Get
		End Property

		Public ReadOnly Property TotalCompraIVA() As AggregateParameter 
			Get
				If _TotalCompraIVA_W Is Nothing Then
					_TotalCompraIVA_W = TearOff.TotalCompraIVA
				End If
				Return _TotalCompraIVA_W
			End Get
		End Property

		Public ReadOnly Property CodProveedor() As AggregateParameter 
			Get
				If _CodProveedor_W Is Nothing Then
					_CodProveedor_W = TearOff.CodProveedor
				End If
				Return _CodProveedor_W
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As AggregateParameter 
			Get
				If _CodUsuario_W Is Nothing Then
					_CodUsuario_W = TearOff.CodUsuario
				End If
				Return _CodUsuario_W
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As AggregateParameter 
			Get
				If _FechaActualizacion_W Is Nothing Then
					_FechaActualizacion_W = TearOff.FechaActualizacion
				End If
				Return _FechaActualizacion_W
			End Get
		End Property

		Public ReadOnly Property NroRemision() As AggregateParameter 
			Get
				If _NroRemision_W Is Nothing Then
					_NroRemision_W = TearOff.NroRemision
				End If
				Return _NroRemision_W
			End Get
		End Property

		Public ReadOnly Property CodOrden() As AggregateParameter 
			Get
				If _CodOrden_W Is Nothing Then
					_CodOrden_W = TearOff.CodOrden
				End If
				Return _CodOrden_W
			End Get
		End Property

		Private _CodCompra_W As AggregateParameter = Nothing
		Private _NroFactura_W As AggregateParameter = Nothing
		Private _Fecha_W As AggregateParameter = Nothing
		Private _Vencimiento_W As AggregateParameter = Nothing
		Private _TipoCompra_W As AggregateParameter = Nothing
		Private _EstadoCompra_W As AggregateParameter = Nothing
		Private _TotalCompra_W As AggregateParameter = Nothing
		Private _TotalCompraSaldo_W As AggregateParameter = Nothing
		Private _TotalCompraIVA_W As AggregateParameter = Nothing
		Private _CodProveedor_W As AggregateParameter = Nothing
		Private _CodUsuario_W As AggregateParameter = Nothing
		Private _FechaActualizacion_W As AggregateParameter = Nothing
		Private _NroRemision_W As AggregateParameter = Nothing
		Private _CodOrden_W As AggregateParameter = Nothing

		Public Sub AggregateClauseReset()

		_CodCompra_W = Nothing
		_NroFactura_W = Nothing
		_Fecha_W = Nothing
		_Vencimiento_W = Nothing
		_TipoCompra_W = Nothing
		_EstadoCompra_W = Nothing
		_TotalCompra_W = Nothing
		_TotalCompraSaldo_W = Nothing
		_TotalCompraIVA_W = Nothing
		_CodProveedor_W = Nothing
		_CodUsuario_W = Nothing
		_FechaActualizacion_W = Nothing
		_NroRemision_W = Nothing
		_CodOrden_W = Nothing
			Me._entity.Query.FlushAggregateParameters()

		End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffAggregateParameter
    End Class	

	Public ReadOnly Property Aggregate() As AggregateClause
		Get
			If _aggregateClause Is Nothing Then
				_aggregateClause = New AggregateClause(Me)
			End If
	
			Return _aggregateClause
		End Get
	End Property
	
	Private _aggregateClause As AggregateClause = Nothing	
#End Region	

	Protected Overrides Function GetInsertCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_COMPRASInsert]" 
	    
		CreateParameters(cmd)
		
		Dim p As SqlParameter
		p = cmd.Parameters(Parameters.CodCompra.ParameterName)
		p.Direction = ParameterDirection.Output
    
		Return cmd 

  	End Function
	
	Protected Overrides Function GetUpdateCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_COMPRASUpdate]" 
		
		CreateParameters(cmd) 
		    
		Return cmd
	
	End Function	
	
	Protected Overrides Function GetDeleteCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_COMPRASDelete]" 
		
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.CodCompra)
		p.SourceColumn = ColumnNames.CodCompra
		p.SourceVersion = DataRowVersion.Current

  
		Return cmd
	
	End Function	
	
	Private Sub CreateParameters(ByVal cmd As SqlCommand)
	
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.CodCompra)
		p.SourceColumn = ColumnNames.CodCompra
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.NroFactura)
		p.SourceColumn = ColumnNames.NroFactura
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Fecha)
		p.SourceColumn = ColumnNames.Fecha
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.Vencimiento)
		p.SourceColumn = ColumnNames.Vencimiento
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.TipoCompra)
		p.SourceColumn = ColumnNames.TipoCompra
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.EstadoCompra)
		p.SourceColumn = ColumnNames.EstadoCompra
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.TotalCompra)
		p.SourceColumn = ColumnNames.TotalCompra
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.TotalCompraSaldo)
		p.SourceColumn = ColumnNames.TotalCompraSaldo
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.TotalCompraIVA)
		p.SourceColumn = ColumnNames.TotalCompraIVA
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodProveedor)
		p.SourceColumn = ColumnNames.CodProveedor
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodUsuario)
		p.SourceColumn = ColumnNames.CodUsuario
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.FechaActualizacion)
		p.SourceColumn = ColumnNames.FechaActualizacion
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.NroRemision)
		p.SourceColumn = ColumnNames.NroRemision
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodOrden)
		p.SourceColumn = ColumnNames.CodOrden
		p.SourceVersion = DataRowVersion.Current


	End Sub	

End Class

End NameSpace

